package com.xcity.game.task;

import com.xcity.game.common.ItemResponse;

import naga.x.game.template.Template;
import naga.x.game.template.TemplateException;
import naga.x.game.template.annotation.Excel;

/**
 * 任务
 * @author yang.li
 *
 */
@Excel(value = "task.xlsx", sheet = 0)
public class TaskTemplate extends Template {

	/** 在列表中的索引 */
	protected int index;
	
	/** 任务名 */
	protected String name;

	/** 任务描述 */
	protected String desc;

	/** 任务类型(0:主线,1:日常) */
	protected byte type;
	
	/** 开放等级(只影响显示和领取)*/
	protected byte needLvl;
	
	/** 是否已弃用(0:正常使用 1:弃用) */
	protected byte ban;

	/** 奖励经验 */
	protected int exp;

	/** 奖励现金 */
	protected int gold;

	/** 奖励钻石 */
	protected int stone;

	/** 奖励荣誉 */
	protected int honor;
	
	/** 奖励物品 */
	protected int[] items;
	protected ItemResponse[] _items = EMPTY;

	/** 完成条件id */
	protected byte conditionId;
	
	/** 完成条件参数 */
	protected int[] conditions;
	
	private static final ItemResponse[] EMPTY = new ItemResponse[0];
	
	public int getIndex() {
		return index;
	}
	
	public void setIndex(int index) {
		this.index = index;
	}
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getDesc() {
		return desc;
	}

	public void setDesc(String desc) {
		this.desc = desc;
	}

	public byte getType() {
		return type;
	}

	public void setType(byte type) {
		this.type = type;
	}

	public int getExp() {
		return exp;
	}

	public void setExp(int exp) {
		this.exp = exp;
	}

	public int getGold() {
		return gold;
	}

	public void setGold(int gold) {
		this.gold = gold;
	}

	public int getStone() {
		return stone;
	}

	public void setStone(int stone) {
		this.stone = stone;
	}

	public int getHonor() {
		return honor;
	}

	public void setHonor(int honor) {
		this.honor = honor;
	}

	public byte getConditionId() {
		return conditionId;
	}

	public void setConditionId(byte conditionId) {
		this.conditionId = conditionId;
	}

	public int[] getConditions() {
		return conditions;
	}

	public void setConditions(int[] conditions) {
		this.conditions = conditions;
	}

	public int[] getItems() {
		return items;
	}

	public void setItems(int[] items) {
		this.items = items;
	}

	public ItemResponse[] getItemObjs() {
		return _items;
	}

	public byte getNeedLvl() {
		return needLvl;
	}

	public void setNeedLvl(byte needLvl) {
		this.needLvl = needLvl;
	}

	public byte getBan() {
		return ban;
	}

	public void setBan(byte ban) {
		this.ban = ban;
	}

	@Override
	public void validate() throws TemplateException {
		int len = items != null ? items.length : 0;
		if (len > 0) {
			_items = new ItemResponse[len >> 1];
			for (int i = 0; i < len; i += 2) {
				int id = items[i];
				int count = items[i + 1];
				 _items[i >> 1] = new ItemResponse(id, count);
			}
		}
		items = null;
	}
}
